#ifndef TCP_IMP_H_
#define TCP_IMP_H_
#include <OCTCommu.h>
#include <Util/onceToken.h>
#include <TCPClientImp.h>
#include <TCPServerImp.h>
#include <memory>

namespace oct_commu
{
	/// ----------------------------------------------------------------------------------------
	/// @brief: TCP实现类
	/// ----------------------------------------------------------------------------------------
	class TCPImp 
	{
	public:
		TCPImp() ;
		virtual ~TCPImp();

		/// --------------------------------------------------------------------------------
		/// @brief: init
		/// --------------------------------------------------------------------------------
		int init(const TCPInit& init_param) ;


		/// --------------------------------------------------------------------------------
		/// @brief: recvSpeed
		/// --------------------------------------------------------------------------------
		int recvSpeed();


		/// --------------------------------------------------------------------------------
		/// @brief: sendSpeed
		/// --------------------------------------------------------------------------------
		int sendSpeed();


		/// --------------------------------------------------------------------------------
		/// @brief: send
		/// --------------------------------------------------------------------------------
		int send(const char* pdata, const size_t len);


		/// --------------------------------------------------------------------------------
		/// @brief: unInit
		/// --------------------------------------------------------------------------------
		int shutdown();


		/// --------------------------------------------------------------------------------
		/// @brief: getLastErrorMsg
		/// --------------------------------------------------------------------------------
		std::string getLastErrorMsg();

		/// -------------------------------------------------------------------------------
		/// @brief:		指定接收数据函数
		/// @param: 	OnRecvDataFunc cb - 回调函数,
		///  @ret:		void
		///				
		/// -------------------------------------------------------------------------------
		int setOnReadFunc(OnNetLinkRecvDataFunc cb);

		/// -------------------------------------------------------------------------------
		/// @brief:		连接事件处理函数
		/// @param: 	OnTCPConnectFunc cb - 
		///  @ret:		int
		///				
		/// -------------------------------------------------------------------------------
		int setOnConnectFunc(OnTCPConnectFunc cb);

		/// -------------------------------------------------------------------------------
		/// @brief:		设置发送数据阻塞后清空缓存事件处理函数
		/// @param: 	OnTCPFlush cb - 
		///  @ret:		int
		///				
		/// -------------------------------------------------------------------------------
		int setOnFlushFunc(OnTCPFlush cb);

		/// -------------------------------------------------------------------------------
		/// @brief:		TCP错误事件处理
		/// @param: 	OnTCPError cb - 
		///  @ret:		int
		///				
		/// -------------------------------------------------------------------------------
		int setOnErrorFunc(OnTCPErrorFunc cb);

	private:		
		int				tcp_type_ = 0;
		/// 客户端
		std::shared_ptr<TCPClientImp> tcp_client_imp_;
		/// 服务端
		TCPServerImp	tcp_server_imp_;
	};
}


#endif ///!TCP_IMP_H_